<template>
  <div>
    <div>
      <span>书名</span>
      <input v-model="book.name" />
    </div>
    <div>
      <span>作者</span>
      <input v-model="book.author" />
    </div>
    <div>
      <span>价格</span>
      <input v-model="book.price" />
    </div>
    <div>
      <button @click="add"> 提交</button>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      book: {}
    }
  },
  methods: {
    add () {
      this.axios.post('http://localhost:8082/book/add', this.book).then(res => {
        if (res.data.affectedRows = 1) {
          this.$router.push('/')
        }
      })
    }
  }

}
</script>

<style lang="less" scoped>
</style>